home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !preview / RCS / c / buttons < prev    next >
Encoding:
Text File  |  1990-07-24  |  3.2 KB  |  149 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    gtoal:1.2;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     91.03.02.13.59.05;  author gtoal;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     91.03.02.13.55.29;  author gtoal;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @Initial release
  22. @
  23.  
  24.  
  25. 1.2
  26. log
  27. @IAY's upgrade
  28. @
  29. text
  30. @/* buttons.c --- handle button changes and various.  */
  31.  
  32. #include "d2rd.h"
  33. #include "menus.h"
  34. #include <stdio.h>
  35. #include <stdlib.h>
  36. #include <string.h>
  37. #include "kernel.h"
  38. #include "template.h"
  39. #include "resspr.h"
  40. #include "res.h"
  41.  
  42. struct display *which_menu;
  43.  
  44. wimp_menustr *iconbar_menu;
  45. menu window_menu, mag_menu, goto_page, saveas_menu;
  46.  
  47. char goto_page_buffer[12];
  48.  
  49. void
  50. handle_buttons (wimp_eventdata *b)
  51. {
  52.   struct display *w;
  53.   wimp_dragstr d;
  54.   wimp_icon ic;
  55.   wimp_mousestr m;
  56.   int i, x, y;
  57.  
  58.   /* Menu on the iconbar icon.  */
  59.  
  60.   if (b->but.m.bbits == wimp_BMID && b->but.m.w == -2 && b->but.m.i == iconbar_icon)
  61.     {
  62.       which_menu = 0;
  63.       wimp_create_menu (iconbar_menu, b->but.m.x - 64, 96 + 2 * 45);
  64.       return;
  65.     }
  66.  
  67.   /* Drag from the saveas menu-window.  */
  68.  
  69.   if (b->but.m.w == saveas && b->but.m.i == SAVEAS_FILEICON && b->but.m.bbits == wimp_BDRAGLEFT)
  70.     {
  71.       wimpt_noerr (wimp_get_point_info (&m));
  72.       wimpt_noerr (wimp_get_icon_info (saveas, SAVEAS_FILEICON, &ic));
  73.       d.window = saveas;
  74.       d.type = wimp_USER_FIXED;
  75.       x = ic.box.x1 - ic.box.x0;
  76.       y = ABS (ic.box.y1 - ic.box.y0);
  77.       d.box.x0 = m.x - x / 2;
  78.       d.box.y0 = m.y - y / 2;
  79.       d.box.x1 = m.x + x / 2;
  80.       d.box.y1 = m.y + y / 2;
  81.       d.parent.x0 = -4242;
  82.       d.parent.y0 = -4242;
  83.       d.parent.x1 = 4242;
  84.       d.parent.y1 = 4242;
  85.       wimpt_noerr (wimp_drag_box (&d));
  86.       return;
  87.     }
  88.  
  89.   /* OK clicked in the saveas menu leaf.  */
  90.  
  91.   if (b->but.m.w == saveas && b->but.m.i == SAVEAS_OKBUTTON)
  92.     {
  93.       if (strchr (saveas_buffer, '.'))
  94.         output_saveas (saveas_buffer);
  95.       else
  96.         fatal ("To save, drag icon to a directory viewer.");
  97.       return;
  98.     }
  99.  
  100.   for (w = windows; w; w = w->next)
  101.     if (w->w_handle == b->but.m.w)
  102.       break;
  103.  
  104.   wimp_get_point_info (&menu_pos);
  105.  
  106.   /* Sink a button event for an unknown window.  */
  107.  
  108.   if (w == NULL)
  109.     return;
  110.  
  111.   if (b->but.m.bbits == wimp_BMID)
  112.     {
  113.       /* Pop up the window menu.  Shade the `Next', `Previous' and `Goto
  114.          page' menu items in case the document only has one page.  */
  115.  
  116.       menu_setflags (window_menu, 1 + MAINMENU_NEXT, 0, w->page->next == NULL || w->page->next->complete == FALSE);
  117.       menu_setflags (window_menu, 1 + MAINMENU_PREVIOUS, 0, w->page == w->file->pages);
  118.       menu_setflags (window_menu, 1 + MAINMENU_GOTO_PAGE, 0, w->file->pages->next == NULL);
  119.  
  120.       /* Tick the approriate \magstep value.  */
  121.  
  122.       for (i = 0; i < 7; i++)
  123.         menu_setflags (mag_menu, 1 + i, w->magstep == i, 0);
  124.  
  125.       /* Tick the 75dpi tweak icon, if active */
  126.       menu_setflags (mag_menu, 8, w->mag_tweak != 1.0, 0);
  127.  
  128.       sprintf (goto_page_buffer, "%d", w->page->dvi_page);
  129.  
  130.       wimp_create_menu (menu_syshandle (window_menu), b->but.m.x - 64, b->but.m.y + 16);
  131.       which_menu = w;
  132.     }
  133. }
  134.  
  135. /* EOF buttons.c */
  136. @
  137.  
  138.  
  139. 1.1
  140. log
  141. @Initial revision
  142. @
  143. text
  144. @d91 1
  145. a91 1
  146.       /* Thick the approriate \magstep value.  */
  147. d95 3
  148. @
  149.